package com.hry.thymeleaf.controller;

import com.hry.thymeleaf.pojo.User;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.ArrayList;
import java.util.List;

/**
 * @author: HRYing
 * @Date: $ $
 * @Description:
 */
@Controller
public class IndexController {

    @GetMapping("/index")
    public String index(Model model) {
        List<User> users = new ArrayList<User>();
        for (int i = 0; i < 10; i++) {
            User user = new User();
            user.setId((long) i);
            user.setName("hry" + i);
            user.setAddress("广州" + i);
            users.add(user);
        }
        model.addAttribute("users", users);
        model.addAttribute("username", "张三");
//        System.out.println("111");
//        System.out.println(users.toString());
        return "index";

    }

}
